﻿<!--#Include File="../../Inc/Const.Asp"-->
<%
Dim Plus
Set Plus = New Cls_Plus
Plus.Open("repair") ' 打开配置文件
Plus.CheckUser ' 权限检查
' 外部提交
If Not Checkpost(True) Then Call Alert(Lang_ErrorPost,Gourl)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>修正</title>
<style type="text/css">
<!--
* {
	font-size: 13px;
}
.STYLE1 {
	font-size: 12px;
	color: #FF0000;
}
-->
</style>
</head>
<body style="background:#E8EDF4">
<%
dim keywords:keywords=Request.Form("keywords"):if keywords="" then:keywords=Plus.Config("contentfilter"):end if
dim act:act=request("act")
dim i,id,title,Sources,descriptions,Diyname,isExist:isExist=false
	Dim Rs,RSobj

if act="do" then
	Set Rs = DB("Select [ID],[Title],[Keywords] From [{pre}Content] Where [Keywords]='' ",3)
	response.write "<table class=""tb""><tr class=""thead"" align='left'><td colspan=""2"">已处理数据</td></tr><tr><td>编号</td><td>标题</td></tr>"
	for i=1 to RS.recordcount
			
		Rs("Keywords")=keywords
		Rs.update
		response.write  "<tr><td>"&RS(0)&"</td><td>"&RS(1)&"</td></tr>" 
		RS.movenext
		if RS.eof then exit for
	next
	response.write  "<tr><td colspan=""2"">看起来已处理完毕</td></tr>" 
	response.write "</table>"
		Call ClsCache()
		Conn.Close : Set Conn = Nothing

elseif act="jan" then

	Set Rs = DB("Select [ID],[Title],[Author],[Source],[Keywords],[Description],[Diyname] From [{pre}Content] ",3)
	response.write "<table class=""tb""><tr class=""thead"" align='left'><td colspan=""2"">已处理数据</td></tr><tr><td>编号</td><td>标题</td></tr>"
	for i=1 to RS.recordcount
		ID=RS(0) : Title=RS(1) : Author=RS(2) : Sources=RS(3) : Keywords=RS(4) : Descriptions = RS(5) : Diyname = RS(6)
		Title=japanEncode(Title) : Author=japanEncode(Author) : Sources=japanEncode(Sources) : Keywords=japanEncode(Keywords) : Descriptions=japanEncode(Descriptions) : Diyname=japanEncode(Diyname) 
		
		if Title<>RS(1) or  Author<>RS(2) or  Sources<>RS(3) or  Keywords<>RS(4) or Descriptions<>RS(5) or Diyname<>RS(6)  then 
		isExist=true 
		else
		isExist=false
		end if
		if isExist then 
		set RSobj=DB("Select [Title],[Author],[Source],[Keywords],[Description],[Diyname] From [{pre}Content] where id="&ID&" ",3)
			RSobj("Title")=Title
			RSobj("Author")=Author
			RSobj("Source")=Sources
			RSobj("Keywords")=Keywords
			'response.write Descriptions
			'response.end
			RSobj("Description")=left(Descriptions,200)
			RSobj("Diyname")=Diyname
			RSobj.update
			response.write  "<tr><td>"&RS(0)&"</td><td>"&Title&"</td></tr>" 
		end if
		RS.movenext
		if RS.eof then exit for
	next
	response.write  "<tr><td colspan=""2"">看起来已处理完毕</td></tr>" 
	response.write "</table>"
	Call ClsCache()
	Conn.Close : Set Conn = Nothing
	
	Function japanEncode(Byval str)
		dim i,existJapan,japanStr
		dim japanArray
		japanArray=array("ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ","パ","ピ","プ","ペ","ポ","ヴ") 
		if isNull(str)  then japanEncode="" : Exit Function
		japanStr=str
		for i=0 to 25
			if instr(japanStr,japanArray(i))>0 then japanStr=replace(japanStr,japanArray(i),"**")
		next
		japanEncode = japanStr
	End Function
		
elseif act="res" then

	response.write "<table class=""tb""><tr class=""thead"" align='left'><td colspan=""2"">已处理数据</td></tr><tr><td>编号</td><td>标题</td></tr>"
	Set Rs = DB("Select [ID],[Title],[Author],[Source],[Keywords],[Description],[Diyname] From [{pre}Content] ",3)
	for i=1 to RS.recordcount
		ID=RS(0) : Title=RS(1) : Author=RS(2) : Sources=RS(3) : Keywords=RS(4) : Descriptions = RS(5) : Diyname = RS(6)
		Title=rep(Title) : Author=rep(Author) : Sources=rep(Sources) : Keywords=rep(Keywords) : Descriptions=rep(Descriptions) : Diyname=rep(Diyname) 
		
		if Title<>RS(1) or  Author<>RS(2) or  Sources<>RS(3) or  Keywords<>RS(4) or Descriptions<>RS(5) or Diyname<>RS(6)  then 
		isExist=true 
		else
		isExist=false
		end if
		if isExist then 
		set RSobj=DB("Select [Title],[Author],[Source],[Keywords],[Description],[Diyname] From [{pre}Content] where id="&ID&" ",3)
			if request.form("Ftitle")=1 then RSobj("Title")=Title
			if request.form("Fauthor")=1 then RSobj("Author")=Author
			if request.form("Fsource")=1 then RSobj("Source")=Sources
			if request.form("Fkeywords")=1 then RSobj("Keywords")=Keywords
			if request.form("FDescription")=1 then RSobj("Description")=left(Descriptions,240)
			if request.form("FDiyname")=1 then RSobj("Diyname")=Diyname
			RSobj.update
			response.write  "<tr><td>"&RS(0)&"</td><td>"&Title&"</td></tr>" 
		end if
		RS.movenext
		if RS.eof then exit for
	next
	if request.form("Fcontent")=1 then 
	response.write  "<tr><td colspan=""2"">以上是文章摘要部分，以下为文章内容部分</td></tr>" 
	
		Set Rs = DB("Select [aID],[content] From [{pre}Content_01] ",3)
		for i=1 to RS.recordcount
			ID=RS(0) : Title=RS(1)
			Title=rep(Title)
			
			if Title<>RS(1) then 
			isExist=true 
			else
			isExist=false
			end if
			if isExist then 
			set RSobj=DB("Select [content] From [{pre}Content_01] where aid="&ID&" ",3)
				RSobj("content")=Title
				RSobj.update
				response.write  "<tr><td>"&RS(0)&"</td><td>"
				if len(title)>20 then
				response.write  left(Title,20)&"..."
				else
				response.write  title
				end if
				response.write  "</td></tr>" 
			end if
			RS.movenext
			if RS.eof then exit for
		next
	end if
	response.write  "<tr><td colspan=""2"">看起来已处理完毕</td></tr>" 
	response.write "</table>"
	Call ClsCache()
	Conn.Close : Set Conn = Nothing

	Function rep(Byval str)
		dim i,existrep,repStr
		dim text1,text2
		text1=request.form("text1")
		text2=request.form("text2")
		dim repArray
		repArray=split(replace(text1," ",""),",")
		if isNull(str)  then rep="" : Exit Function
		repStr=str
		for i=0 to ubound(repArray)
			if instr(repStr,repArray(i))>0 then repStr=replace(repStr,repArray(i),text2)
		next
		rep = left(repStr,248) '防止字段过长
	End Function

else
%>

<div style="padding-top:10px">
<b style="font-size:14px;">→填补文章的关键词Tags</b>
<form id="frm" name="frm" method="post" action="?act=do" style="margin:2px;">
  将空白关键词部分替换成以下内容，以显示相关文章：<br />
<input name="keywords" type="Username" value="<% = Plus.Config("keywords") %>" accesskey="n" tabindex="1" size="20" style="border:1px solid #999;font-size:14px;width:200px"/>
<input type="submit" value="开始" style="background:#fff;border:1px solid #999;padding:2px 2px 0px 2px;margin:20px 0 0 0;border-width:1px 3px 1px 3px" />
</form>
</div>

<div style="padding-top:10px">
<b style="font-size:14px;">→修复内存溢出</b><br />
<br />
<a href="?act=jan"  style="background:#fff;border:1px solid #999;padding:2px 2px 0px 2px;margin:20px 0 0 0;border-width:1px 3px 1px 3px" >干掉日文</a></div>

<div style="padding-top:10px">
<b style="font-size:14px;">→批量文字替换</b>
<form id="frm" name="frm" method="post" action="?act=res" style="margin:2px;">
  <p>搜索的文字：
    <input name="text1" type="text1" value="" accesskey="n" tabindex="1" size="20" style="border:1px solid #999;font-size:14px;width:200px"/>
    (支持英文,的词组)<br />
      <br />
    替换成：
  <input name="text2" type="text2" value="" accesskey="n" tabindex="2" size="20" style="border:1px solid #999;font-size:14px;width:200px"/>
    (不支持分组)<br />
    <br />
	替换范围包括：
	<input name="Ftitle" type="checkbox" value="1" />标题
	<input name="Fauthor" type="checkbox" value="1" />作者
	<input name="Fsource" type="checkbox" value="1" />来源
	<input name="Fkeywords" type="checkbox" value="1" />关键词
	<input name="FDescription" type="checkbox" value="1" />文章描述
	<input name="FDiyname" type="checkbox" value="1" />DIY文件名(不常用)
	<input name="Fcontent" type="checkbox" value="1" checked="checked" />文章内容<br />
      <b style="font-size:14px;">注意：</b><br />
      <span class="STYLE1">替换数字的时候图片可能会导致图片路径错误而不显示；<br />
支持搜索词组，比如网址&quot;www.x.com,x.com,www.xx.com&quot;→&quot;www.a.com&quot;方便采集后数据批量替换，减轻操作；<br />
因为描述字段字数关系，这里截取描述字段240个字符，其它字段验证长度截取248个字符,请注意操作。<br />
      </span>
      <input type="submit" value="开始" style="background:#fff;border:1px solid #999;padding:2px 2px 0px 2px;margin:20px 0 0 0;border-width:1px 3px 1px 3px" />
    </p>
  </form>
</div>


<%
end if
%>
<br /><a href=? style="background:#fff;border:1px solid #999;padding:2px 2px 0px 2px;margin:20px 0 0 0;border-width:1px 3px 1px 3px">返回</a>
<br><div style="text-align:center;font-size:12px;">
5UCMS 内容替换插件 Zach作品 <a href="http://www.disman.com.cn" target="_blank">http://www.disman.com.cn</a>
</div>
</body>
</html>
<%
Set Plus = Nothing
%>
